<template>
  <div class="classify">
    <p style="text-align: center;font-size:20px;">分类</p>
   <div class="left" >
      <div v-for="(item,index) in categoryList" :key="index" :class="data.indexa===index?'active':''" @click="tab(index,item.id)">
        {{item.name}}
      </div>
    </div>
    <div class="right">
      
        <dl  v-for="(item,index) in classList" :key="index">
          <dt>
            <img :src='item.image' alt=""  @click="tz(item.id)">
          </dt>
          <dd>
            {{item.name}}
          </dd>
        </dl>
    </div>
  </div>
</template>

<script>
import { getHomeList,getClassify,getClassDropList,getClassDetail } from "@/api/classify";
import { defineComponent, computed, reactive } from "vue";
import { useStore } from "vuex";

export default defineComponent({
  setup(props, context) {
    const data=reactive({
      indexa:0
    })
    let store = useStore();
    store.dispatch("Classify/getHomeList", { mid: 0 });

    function tab(id,obj){
      data.indexa=id
      store.dispatch("Classify/getClassify",{mid:0,id:obj})
    }
    function tz(idq){
      console.log(idq);
      store.dispatch("Classify/getClassDropList",{mid:0,rankId:idq})
      store.dispatch("Classify/getClassDetail",{mid:0,drops:'',rankId:idq})
      
      this.$router.push('/classify')
    }
    return {
      data,
      tz,
      tab,
      categoryList: computed(() => store.state.Classify.rankCategoryList),
      classify: computed(() => store.state.Classify.classify),
      classList:computed(() => store.state.Classify.classList)
    };
    
  },
 
});
</script>

<style>
.left{
  float: left;
  width: 20%;
  height: 100%;
}
.left div{
  line-height: 30px;
  margin: 20px;
}
.active{
  color: red;
}
.right{
  width: 80%;
  float: left;
  margin-top: 20px;
}
.right dl dt img{
 width: 60px;
 height: 60px;
}
.right dl{
  float: left;
  text-align: center;
  width: 80px;
  height: 100px;
  margin: 10px;
  line-height: 25px;
}
</style>
